home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / FWShape.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.8 KB  |  197 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWShape.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWSHAPE_H
  11. #define FWSHAPE_H
  12.  
  13. #ifndef FWPOINT_H
  14. #include "FWPoint.h"
  15. #endif
  16.  
  17. #ifndef FWRECT_H
  18. #include "FWRect.h"
  19. #endif
  20.  
  21. #ifndef SLGRDEF_H
  22. #include "SLGrDef.h"
  23. #endif
  24.  
  25. #ifndef FWINK_H
  26. #include "FWInk.h"
  27. #endif
  28.  
  29. #ifndef FWSTYLE_H
  30. #include "FWStyle.h"
  31. #endif
  32.  
  33. #ifndef FWFONT_H
  34. #include "FWFont.h"
  35. #endif
  36.  
  37. #ifndef FWSTDDEF_H
  38. #include "FWStdDef.h"
  39. #endif
  40.  
  41. // ----- Foundation Includes -----
  42.  
  43. #ifndef FWEXCLIB_H
  44. #include "FWExcLib.h"
  45. #endif
  46.  
  47. //========================================================================================
  48. //    Forward Declarations
  49. //========================================================================================
  50.  
  51. class FW_CGraphicContext;
  52. class FW_CReadableStream;
  53. class FW_CWritableStream;
  54.  
  55. //========================================================================================
  56. //    class FW_CShape
  57. //========================================================================================
  58.  
  59. class FW_CShape
  60. {
  61. public:
  62.     FW_DECLARE_CLASS
  63.     FW_DECLARE_AUTO(FW_CShape)
  64.  
  65. //----------------------------------------------------------------------------------------
  66. //    Constructors/Destructors
  67. //
  68. public:
  69.     virtual ~ FW_CShape();
  70.  
  71. protected:
  72.     FW_CShape(FW_ERenderVerbs renderVerb,
  73.               const FW_CInk& ink,
  74.               const FW_CStyle& style,
  75.               const FW_CFont& font);
  76.  
  77.     FW_CShape(const FW_CShape& other);
  78.     FW_CShape(FW_CReadableStream& stream);
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    Operators
  82. //
  83. public:
  84.     FW_CShape& operator=(const FW_CShape& other);
  85.  
  86. //----------------------------------------------------------------------------------------
  87. //    New API
  88. //
  89. public:
  90.     // ----- Memory Management -----
  91.     virtual void                Purge();
  92.  
  93.     // ----- Rendering -----
  94.     virtual void                 Render(FW_CGraphicContext& gc) const = 0;
  95.     
  96.     // ----- Hit Testing -----
  97.     virtual FW_Boolean         HitTest(FW_CGraphicContext& gc,
  98.                                         const FW_CPoint& test,
  99.                                         FW_Fixed tolerance) const = 0;
  100.     
  101.     // ----- Copying -----
  102.     virtual FW_CShape*            Copy() const = 0;
  103.     
  104.     // ----- Transform -----
  105.     virtual void                Transform(Environment *ev, ODTransform* transform) = 0;
  106.     virtual void                InverseTransform(Environment *ev, ODTransform* transform) = 0;
  107.  
  108.     virtual void                MoveShape(FW_Fixed deltaX, FW_Fixed deltaY) = 0;
  109.     virtual void                MoveShapeTo(FW_Fixed x, FW_Fixed y) = 0;
  110.     
  111.     virtual void                Inset(FW_Fixed h, FW_Fixed v) = 0;
  112.     void                        Inset(FW_Fixed f)
  113.                                     {Inset(f, f);}
  114.                                     
  115.     // ----- Bounds -----
  116.     virtual void                 GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const = 0;
  117.     
  118.     // ----- Anchor Points -----
  119.     virtual FW_CPoint            GetAnchorPoint() const = 0;
  120.     
  121.     // ----- Archiving -----
  122.     virtual void                Flatten(FW_CWritableStream& stream) const;
  123.     static void                 Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object);
  124.     
  125.     // ----- Getters/Setters -----
  126.     FW_ERenderVerbs                GetRenderVerb() const
  127.                                     {return fRenderVerb;}
  128.     virtual void                SetRenderVerb(FW_ERenderVerbs renderVerb);
  129.                         
  130.     // ----- Ink access -----
  131.     FW_CInk&                    GetInk()
  132.                                     {return fInk;}
  133.  
  134.     const FW_CInk&                GetInk() const
  135.                                     {return fInk;}
  136.  
  137.     FW_CInk&                    GetUnSharedInk();
  138.                                     
  139.     virtual void                SetInk(const FW_CInk& newInk);
  140.  
  141.     void                        GetForeColor(FW_CColor& color) const
  142.                                     {fInk.GetForeColor(color);}
  143.  
  144.     void                        GetBackColor(FW_CColor& color) const
  145.                                     {fInk.GetBackColor(color);}
  146.  
  147.     FW_TransferModes            GetTransferMode() const
  148.                                     {return fInk.GetTransferMode();}
  149.  
  150.     // ----- Style access -----
  151.     FW_CStyle&                    GetStyle()
  152.                                     {return fStyle;}
  153.  
  154.     const FW_CStyle&            GetStyle() const
  155.                                     {return fStyle;}
  156.  
  157.     FW_CStyle&                    GetUnSharedStyle();
  158.  
  159.     virtual void                SetStyle(const FW_CStyle& newStyle);
  160.     
  161.     FW_Fixed                    GetPenSize() const
  162.                                     {return fStyle.GetPenSize();}
  163.  
  164.     FW_CPattern                    GetPattern() const
  165.                                     {return fStyle.GetPattern();}
  166.  
  167.     // ----- Font access -----
  168.     FW_CFont&                    GetFont()
  169.                                     {return fFont;}
  170.  
  171.     const FW_CFont&                GetFont() const
  172.                                     {return fFont;}
  173.  
  174.     FW_CFont&                    GetUnSharedFont();
  175.  
  176.     virtual void                SetFont(const FW_CFont& newFont);
  177.     
  178.     FW_Fixed                     GetFontSize() const
  179.                                     {return fFont.GetFontSize();}
  180.  
  181.     FW_FontStyle                 GetFontStyle() const
  182.                                     {return fFont.GetFontStyle();}
  183.  
  184.     void                        GetFontName(FW_CString& fontName) const
  185.                                     {fFont.GetFontName(fontName);}
  186. //----------------------------------------------------------------------------------------
  187. //    Data Members
  188. //
  189. protected:
  190.     FW_ERenderVerbs                fRenderVerb;
  191.     FW_CInk                        fInk;
  192.     FW_CStyle                    fStyle;
  193.     FW_CFont                    fFont;
  194. };
  195.  
  196. #endif
  197.